package com.gmall.product.controller;

import com.gmall.common.result.Result;
import com.gmall.model.product.BaseTrademark;
import com.gmall.model.product.dto.CategoryTrademarkDTO;
import com.gmall.product.service.BaseCategoryTrademarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/product/baseCategoryTrademark")
public class BaseCategoryTrademarkController {

    @Autowired
    BaseCategoryTrademarkService baseCategoryTrademarkService;

    @GetMapping("findTrademarkList/{category3Id}")
    public Result<List<BaseTrademark>> findTrademarkList(@PathVariable Long category3Id){
        return baseCategoryTrademarkService.findTrademarkList(category3Id);
    }

    /**
     * 获取第三级分类 category3Id，没有的品牌
     * @param category3Id
     * @return
     */
    @GetMapping("findCurrentTrademarkList/{category3Id}")
    public Result<List<BaseTrademark>> findCurrentTrademarkList(@PathVariable Long category3Id){
        return baseCategoryTrademarkService.findCurrentTrademarkList(category3Id);
    }

    @DeleteMapping("remove/{category3Id}/{trademarkId}")
    public Result<String> removeBaseCategoryTradeMark(@PathVariable Long category3Id,@PathVariable Long trademarkId) {
        return baseCategoryTrademarkService.removeBaseCategoryTradeMark(category3Id,trademarkId);
    }

    @PostMapping("save")
    public Result<String> saveBaseCategoryTradeMark(@RequestBody CategoryTrademarkDTO categoryTrademarkDTO) {
        return baseCategoryTrademarkService.saveBaseCategoryTradeMark(categoryTrademarkDTO);
    }


}
